package cn.gayaguoguo.gritemtags;

import org.bukkit.plugin.java.JavaPlugin;

import cn.gayaguoguo.gritemtags.command.GRIT_Command;
import cn.gayaguoguo.gritemtags.listener.ItemSpawnListener;
import cn.gayaguoguo.gritemtags.manager.ConfigManager;
import cn.gayaguoguo.gritemtags.util.ItemNameUtil;
import cn.gayaguoguo.gritemtags.util.Metrics;
import cn.gayaguoguo.gritemtags.util.UpdateNotify;

public class GrItemTags extends JavaPlugin{
	
	private static GrItemTags plugin;
	
	private ConfigManager configManager;
	
	@Override
	public void onEnable() {
		plugin = this;
		getServer().getPluginManager().registerEvents(new ItemSpawnListener(plugin), plugin);
		getCommand("grit").setExecutor(new GRIT_Command(plugin));
		getCommand("grit").setTabCompleter(new GRIT_Command(plugin));
		load();
		getServer().getPluginManager().registerEvents(new UpdateNotify(plugin), plugin);	
		new Metrics(plugin);
	}
	
	public void load(){
		saveDefaultConfig();
		reloadConfig();
		configManager = new ConfigManager(plugin);
		ItemNameUtil.inits(plugin);
	}
	
	public static GrItemTags getInstance(){
		return plugin;
	}

	public ConfigManager getConfigManager(){
		return configManager;
	}
}
